package com.xiaoy.core.report.fusionchart.eg.action;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xiaoy.core.report.fusionchart.eg.model.Doughnut;
import com.xiaoy.core.report.fusionchart.radarChart.util.XMLDataGenerator;

public class Index extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		List<Doughnut> list = new ArrayList<Doughnut>();
		Doughnut d1 = new Doughnut("France", 10);
		Doughnut d2 = new Doughnut("India", 12);
		Doughnut d3 = new Doughnut("Brazil", 18);
		Doughnut d4 = new Doughnut("USA", 8);
		Doughnut d5 = new Doughnut("Australia", 10);
		Doughnut d6 = new Doughnut("Japan", 7);
		Doughnut d7 = new Doughnut("England", 5);
		Doughnut d8 = new Doughnut("Nigeria", 12);
		Doughnut d9 = new Doughnut("Italy", 8);
		Doughnut d10 = new Doughnut("China", 10);
		Doughnut d11 = new Doughnut("Canada", 19);
		Doughnut d12 = new Doughnut("Germany", 15);
		list.add(d1);
		list.add(d2);
		list.add(d3);
		list.add(d4);
		list.add(d5);
		list.add(d6);
		list.add(d7);
		list.add(d8);
		list.add(d9);
		list.add(d10);
		list.add(d11);
		list.add(d12);
		request.getSession().setAttribute("list", list);

		String osXMLData = null;
		osXMLData = XMLDataGenerator.getCRRankXML(list, "");

		request.setAttribute("osXMLData", osXMLData);

		request.getRequestDispatcher("index.jsp").forward(request, response);
	}

}
